package com.yb.xczx.cloud.auth.bean;

import com.yb.core.enums.LoginTypeEnum;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/5/18 13:29
 * FileName: XczxUserPassAuthentionToken
 * Description:
 */
public class XczxUserPassAuthenticationToken extends XczxAbstractAuthenticationToken {


    public XczxUserPassAuthenticationToken(XczxSysUser xczxSysUser) {
        super(xczxSysUser);
    }

    public XczxUserPassAuthenticationToken(XczxSysUser xczxSysUser, Collection<? extends GrantedAuthority> authorities) {
        super(xczxSysUser, authorities);
    }

    @Override
    public String getLoginType() {
        return LoginTypeEnum.USER_PASS.getLoginType();
    }


    public static XczxUserPassAuthenticationToken unauthenticated(XczxSysUser xczxSysUser) {
        return new XczxUserPassAuthenticationToken(xczxSysUser);
    }

    /**
     * This factory method can be safely used by any code that wishes to create a
     * authenticated <code>UsernamePasswordAuthenticationToken</code>.
     * @param
     * @param
     * @return UsernamePasswordAuthenticationToken with true isAuthenticated() result
     *
     * @since 5.7
     */
    public static XczxUserPassAuthenticationToken authenticated(XczxSysUser xczxSysUser,
                                                                Collection<? extends GrantedAuthority> authorities) {
        return new XczxUserPassAuthenticationToken(xczxSysUser, authorities);
    }
}
